package com.lanqiao.javaparkinglot.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
@EnableWebMvc

public class WebConfig implements WebMvcConfigurer {

    /**
     * Cors 全局配置
     * @param registry
     */
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                //前端访问地址
                .allowedOrigins("http://localhost:8080")
                .allowCredentials(true)
                .allowedHeaders("*")
                .allowedMethods("GET","POST","DELETE","PUT","OPTION")
                .maxAge(3600);

    }
}


